import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';

import '../../../../base/utils/logger.dart';
import '../../../../data/api.dart';
import '../../../../data/models/get_info_res.dart';
import '../../../../main_service.dart';

class DoctorMinePageController extends GetxController {
  //TODO: Implement DoctorMinePageController

  UserInfo? userInfo;
  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    getUserInfo();
  }


  @override
  void onClose() {
    super.onClose();
  }
  getUserInfo()async{
    try {
      EasyLoading.show();
      UserInfo? userInfo = await Api.getUserInfo();
      this.userInfo = userInfo;
      if (userInfo != null) {
        Get.find<MainService>().userInfo = userInfo!;
      }
    } catch (e) {
      loggy.error(e);
    }finally{
      EasyLoading.dismiss();
    }
  }

  get avatarUrl => userInfo?.avatar;
}
